// pages/userCenter/medicalReport/medicalReport.js
import { post } from '../../../utils/request.js'
import global from '../../../utils/global.js'
let that
Page({

  /**
   * 页面的初始数据
   */
  data: {
    listReport:[],
    userId: wx.getStorageSync("useInfo").id,
    page: 1,
    height: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
    wx.getSystemInfo({
      success: (res) => {
        that.setData({
          height: res.windowHeight 
        })
      }
    })
    that.getCheckDataHistoryList(that.data.page);
  },
  // 获取体检报告
  getCheckDataHistoryList(page){
    let param = {
      page: that.data.page++,
      userId:that.data.userId
      // userId: "1738"
    }
    post(global.apiUrl.reportListNew, param, function (res) {
      console.log(res.obj)
      if (!res.more) {
        wx.showToast({
          title: '已经加载完数据',
          icon: 'loading',
          duration: 1000
        })

        return
      }
      let curArr = that.data.listReport.concat(res.obj)
      that.setData({
        listReport: curArr
      })

    })
  },
  /**
 * 页面相关事件处理函数--监听用户下拉动作
 */
  onPullDownRefresh: function () {
    // 停止下拉动作
    wx.stopPullDownRefresh();

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  lower: function () {
    // 显示加载图标
    wx.showLoading({
      title: '玩命加载中',
    })
    // 页数+1
    that.getCheckDataHistoryList(that.data.page)
  },
  // 
  reportDetail:(e)=>{
    console.log(e.currentTarget.dataset.id)
    wx.navigateTo({
      url: 'reportDetail/reportDetail?summarizeId='+e.currentTarget.dataset.id,
    })
  }

})